home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Mac Power 1997 December
/
MACPOWER-1997-12.ISO.7z
/
MACPOWER-1997-12.ISO
/
AMUG
/
PROGRAMMING
/
Raven 1.2 Examples.sit
/
Raven 1.2 Examples
/
Quill
/
Source
/
DisabledHelpEditor.cpp
< prev
next >
Wrap
Text File
|
1997-09-03
|
6KB
|
243 lines
/*
* File: DisabledHelpEditor.cpp
* Summary: A view that knows how to edit a control's disabled help message.
* Written by: Jesse Jones
*
* Copyright ゥ 1997 Jesse Jones.
* For conditions of distribution and use, see copyright notice in ZTypes.h
*
* Change History (most recent first):
*
* <2> 4/06/97 JDJ Updated for new style TSubPaneIterator.
* <1> 2/05/97 JDJ Created
*/
#include "DisabledHelpEditor.h"
#include <ZRadioButton.h>
#include <ZStaticText.h>
#include <ZStringUtils.h>
#include <ZTextBox.h>
// ===================================================================================
// class CEditDisabledHelpCommand
// ===================================================================================
//---------------------------------------------------------------
//
// CEditDisabledHelpCommand::~CEditDisabledHelpCommand
//
//---------------------------------------------------------------
CEditDisabledHelpCommand::~CEditDisabledHelpCommand()
{
}
//---------------------------------------------------------------
//
// CEditDisabledHelpCommand::CEditDisabledHelpCommand
//
//---------------------------------------------------------------
CEditDisabledHelpCommand::CEditDisabledHelpCommand(TControl* pane, const SControlInfo& oldInfo, const SControlInfo& newInfo) : Inherited(pane, oldInfo, newInfo)
{
}
//---------------------------------------------------------------
//
// CEditDisabledHelpCommand::UpdatePane
//
//---------------------------------------------------------------
void CEditDisabledHelpCommand::UpdatePane(const SControlInfo& info)
{
mPane->SetDisabledHelpMessage(info.disabledMesg);
}
#pragma mark -
// ===================================================================================
// CDisabledHelpEditor
// ===================================================================================
static TReanimatorRegister<CDisabledHelpEditor> sCheckedHelpEditorRegistrar;
//---------------------------------------------------------------
//
// CDisabledHelpEditor::~CDisabledHelpEditor
//
//---------------------------------------------------------------
CDisabledHelpEditor::~CDisabledHelpEditor()
{
}
//---------------------------------------------------------------
//
// CDisabledHelpEditor::CDisabledHelpEditor
//
//---------------------------------------------------------------
CDisabledHelpEditor::CDisabledHelpEditor(TView* superView) : Inherited(superView)
{
mType = '????';
}
//---------------------------------------------------------------
//
// CDisabledHelpEditor::Create [static]
//
//---------------------------------------------------------------
MReanimatable* CDisabledHelpEditor::Create(MReanimatable* parent)
{
return new CDisabledHelpEditor(dynamic_cast<TView*>(parent));
}
//---------------------------------------------------------------
//
// CDisabledHelpEditor::OnReanimated
//
//---------------------------------------------------------------
void CDisabledHelpEditor::OnReanimated()
{
Inherited::OnReanimated();
TSubPaneIterator iter = this->begin();
while (iter != this->end()) {
TPane* pane = *iter;
++iter;
if (TRadioButton* button = dynamic_cast<TRadioButton*>(pane))
button->AddListener(this);
}
}
//---------------------------------------------------------------
//
// CDisabledHelpEditor::OnBroadcast
//
//---------------------------------------------------------------
void CDisabledHelpEditor::OnBroadcast(const SControlMessage& mesg)
{
if (mesg.value == 1) {
mType = StrToID(mesg.message);
this->TogglePanes();
}
}
//---------------------------------------------------------------
//
// CDisabledHelpEditor::TogglePanes
//
//---------------------------------------------------------------
void CDisabledHelpEditor::TogglePanes()
{
TStaticText* caption = dynamic_cast<TStaticText*>(this->FindSubPane("ID Caption"));
if (mType == 'STRL') {
caption->Hide();
this->FindSubPane("String Literal")->Show();
this->FindSubPane("Rsrc ID")->Hide();
} else {
caption->SetText(LoadAppString("Rsrc ID:"));
this->FindSubPane("String Literal")->Hide();
this->FindSubPane("Rsrc ID")->Show();
}
if (mType == 'STR#') {
this->FindSubPane("Index Caption")->Show();
this->FindSubPane("STR# Index")->Show();
} else {
this->FindSubPane("Index Caption")->Hide();
this->FindSubPane("STR# Index")->Hide();
}
}
//---------------------------------------------------------------
//
// CDisabledHelpEditor::GetEditorInfo
//
//---------------------------------------------------------------
SControlInfo CDisabledHelpEditor::GetEditorInfo() const
{
SControlInfo info;
TTextBox* id = dynamic_cast<TTextBox*>(this->FindSubPane("Rsrc ID"));
switch (mType) {
case 'STR ':
case 'TEXT':
case 'PICT':
info.disabledMesg = THelpMessage(mType, id->GetValue());
break;
case 'STR#':
TTextBox* index = dynamic_cast<TTextBox*>(this->FindSubPane("STR# Index"));
info.disabledMesg = THelpMessage(mType, id->GetValue(), index->GetValue());
break;
case 'STRL':
TTextBox* str = dynamic_cast<TTextBox*>(this->FindSubPane("String Literal"));
info.disabledMesg = THelpMessage(str->GetText());
break;
default:
DEBUGSTR("CDisabledHelpEditor::GetHelpMesg had a bogus type.");
}
return info;
}
//---------------------------------------------------------------
//
// CDisabledHelpEditor::SetEditorInfo
//
//---------------------------------------------------------------
void CDisabledHelpEditor::SetEditorInfo(const SControlInfo& info)
{
mType = info.disabledMesg.GetType();
TTextBox* id = dynamic_cast<TTextBox*>(this->FindSubPane("Rsrc ID"));
switch (mType) {
case 'STR ':
case 'TEXT':
case 'PICT':
id->SetValue(info.disabledMesg.GetID());
break;
case 'STR#':
TTextBox* index = dynamic_cast<TTextBox*>(this->FindSubPane("STR# Index"));
id->SetValue(info.disabledMesg.GetID());
index->SetValue(info.disabledMesg.GetIndex());
break;
case 'STRL':
TTextBox* str = dynamic_cast<TTextBox*>(this->FindSubPane("String Literal"));
str->SetText(info.disabledMesg.GetStringLiteral());
break;
default:
DEBUGSTR("CDisabledHelpEditor::SetHelpMesg had a bogus type.");
}
TRadioButton* button = dynamic_cast<TRadioButton*>(this->FindSubPane(IDToStr(mType)));
if (button != nil)
button->SetValue(1);
this->TogglePanes();
}